﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Negocio;
namespace Precentacion1
{
    public partial class FormMarcas : Form
    {
        public FormMarcas()
        {
            InitializeComponent();
            this.ConfigurarDataGridView(dataGridViewMarcas);
            this.dataGridViewMarcas.DataSource = admMarcas.ListarMarcas("");
            dataGridViewMarcas.Columns["IdMarca"].Visible = false;
        }

        private void buttonBuscar_Click(object sender, EventArgs e)
        {
          this.dataGridViewMarcas.DataSource = admMarcas.ListarMarcas(this.textBoxValMarca.Text);
          dataGridViewMarcas.Columns["IdMarca"].Visible = false;
        }

        private void buttonAgregar_Click(object sender, EventArgs e)
        {
            if (this.textBoxValMarcaNueva.Text != "")
            {
                admMarcas.AgregarMarca(this.textBoxValMarcaNueva.Text);
              this.dataGridViewMarcas.DataSource =  admMarcas.ListarMarcas("");
              dataGridViewMarcas.Columns["IdMarca"].Visible = false;
            }
            else 
            {
                MessageBox.Show("Ingrese una Marca Nueva");
            }

        }
        private void ConfigurarDataGridView(DataGridView paramDataGridView)
        {
            
            paramDataGridView.ReadOnly = true;
            paramDataGridView.MultiSelect = false;
            paramDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            paramDataGridView.RowHeadersVisible = false;
            paramDataGridView.AllowUserToResizeRows = false;
            paramDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            paramDataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue;
            
        }
    }
}
